package com.yixq.soa.service.user.service.impl;

import java.util.List;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList;
import com.yixq.soa.service.comm.utils.BeanCopyUtil;
import com.yixq.soa.service.user.dao.RpPayProductMapper;
import com.yixq.soa.service.user.entity.RpPayProduct;
import com.yixq.soa.service.user.service.RpPayProductService;
import com.yixq.soa.service.user.vo.RpPayProductVo;
@Service
public class RpPayProductServiceImpl implements RpPayProductService{
	@Autowired
	private RpPayProductMapper rpPayProductMapper;
	@Override
	public RpPayProductVo selectById(String id) {
		RpPayProduct entity=rpPayProductMapper.selectByPrimaryKey(id);
		if(null==entity){
			return null;
		}
		RpPayProductVo  vo=new RpPayProductVo ();
		BeanUtils.copyProperties(entity, vo);
		return vo;
	}

	@Override
	public boolean deleteById(String id) {
		int i=rpPayProductMapper.deleteByPrimaryKey(id);
		return i>0?true:false;
	}

	@Override
	public boolean insert(RpPayProductVo rpPayProductVo) {
		RpPayProduct entity=new RpPayProduct();
		BeanUtils.copyProperties(rpPayProductVo, entity);
		int i=rpPayProductMapper.insert(entity);
		return i>0?true:false;
	}

	@Override
	public boolean updateById(RpPayProductVo rpPayProductVo) {
		RpPayProduct entity=new RpPayProduct();
		BeanUtils.copyProperties(rpPayProductVo, entity);
		int i=rpPayProductMapper.updateByPrimaryKey(entity);
		return i>0?true:false;
	}

	@Override
	public PageList<RpPayProductVo> getRpPayProductVoListByAuditStatus(String auditStatus, PageBounds bounds) {
		RpPayProduct entity= new RpPayProduct();
		entity.setAuditStatus(auditStatus);
		PageList<RpPayProduct> pageList = rpPayProductMapper.queryRpPayProductList(entity, bounds);
		PageList<RpPayProductVo> pageListVo = new PageList<>(pageList.getPaginator());
		List<RpPayProductVo> list = BeanCopyUtil.copyList(pageList, RpPayProductVo.class);
		pageListVo.addAll(list);
		return pageListVo;
	}

}
